#@bootStrapLayout("商户管理信息界面-同步微信文章图片")
#define bootStrapMain()
<div class="container">
    #include("../../common/header.html")
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li><a href="#">主页</a></li>
            <li class="active">微信文章同步</li>
            <li></li>
        </ol>
    </div>

    <div class="col-md-12" >
    	
    	<div class="col-md-12" id="tips" style="display:none">
	        <div class="alert alert-success" role="alert">
	            <strong id="tipsMsg">  正在同步微信文章请稍候....</strong>
	        </div>
	    </div>
    	
        <div class="col-md-6 col-md-offset-1">
            <form class="form-horizontal" id="submitForm">
               <div class="form-group">
				    <label for="title" class="col-sm-2 control-label">文章URL</label>
				    <div class="col-sm-10">
				        #@textAreaInput("url","url","请输入标题信息...","")
				    </div>
				</div>
				<div class="form-group">
				    <label for="title" class="col-sm-2 control-label">标题信息</label>
				    <div class="col-sm-10">
				        #@textInput("text","activity.name","name","请输入标题信息...",article.title??'')
				    </div>
				</div>
				<div class="form-group">
				    <label for="content" class="col-sm-2 control-label">内容详情</label>
				    <div class="col-sm-10">
				        #@kindEditorInput("activity.content","")
				    </div>
				</div>
				<div class="form-group">
				    <div class="col-sm-offset-8 col-sm-10">
				        <button type="button" id="submitBtn" class="btn btn-primary">点我保存</button>
				        <button type="button" id="syncBtn" class="btn btn-primary">点我同步</button>
				    </div>
				</div>
            </form>
        </div>
    </div>
</div>
#end


#define bootStrapCss()
<link rel="stylesheet"
      href="#(contextPath)/assets/lib/kindeditor/themes/default/default.css" />
<link rel="stylesheet"
      href="#(contextPath)/assets/lib/kindeditor/plugins/code/prettify.css" />

#end

#define bootStrapJs()
<script charset="utf-8" src="#(contextPath)/assets/lib/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="#(contextPath)/assets/lib/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="#(contextPath)/assets/lib/kindeditor/plugins/code/prettify.js"></script>

    <script>
    	var editor ;
        KindEditor.ready(function(K) {
        	editor= K.create('textarea[name="activity.content"]', {
	        cssPath : '#(contextPath)/assets/lib/kindeditor/plugins/code/prettify.css',
	        uploadJson : '#(contextPath)/travel/uploadForKindEditor',
	        //fileManagerJson : '#(contextPath)/assets/admin_bootstrap/js/kindeditor/jsp/file_manager_json.jsp',
	        afterBlur: function () { editor.sync();},
	        });
	    });
       
		$("#syncBtn").click(function(){
	        $("#tips").show();
			$.ajax({
	        "url":"#(contextPath)/travel/article/doWxSync",
	        "method":"post",
	        "data":{"url":$("#url").val()},
	        "success":function (resp) {
	            	if(resp.result){
		                $("#name").val(resp.data.name);
		                editor.html(resp.data.content);
		                editor.sync();
		                $("#tipsMsg").html("文章同步完成，请继续相关操作");
	                }
	            }
	        })
	    })
	    
	    $("#submitBtn").click(function(){
	        $.ajax({
	        "url":"#(contextPath)/travel/activity/doSaveWxActivity",
	        "method":"post",
	        "data":$("#submitForm").serialize(),
	        "success":function (resp) {
	            if(resp.result){
	                layer.msg(resp.data);
	                $("#submitForm")[0].reset();
	                }else{
	                layer.msg(resp.data);
	                }
	            }
	        })
	    })
     #@webUploaderInit()
    </script>
#end
